/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entidade.persistencia;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author victorinox
 */
@Entity
@Table(name = "usuario", catalog = "carlossa03", schema = "")
@NamedQueries({@NamedQuery(name = "Usuario.findAll", query = "SELECT u FROM Usuario u"), @NamedQuery(name = "Usuario.findByUsuarioId", query = "SELECT u FROM Usuario u WHERE u.usuarioId = :usuarioId"), @NamedQuery(name = "Usuario.findByNome", query = "SELECT u FROM Usuario u WHERE u.nome = :nome"), @NamedQuery(name = "Usuario.findByEmail", query = "SELECT u FROM Usuario u WHERE u.email = :email"), @NamedQuery(name = "Usuario.findBySenha", query = "SELECT u FROM Usuario u WHERE u.senha = :senha"), @NamedQuery(name = "Usuario.findByDataUltimoLogin", query = "SELECT u FROM Usuario u WHERE u.dataUltimoLogin = :dataUltimoLogin"), @NamedQuery(name = "Usuario.findByDddi1", query = "SELECT u FROM Usuario u WHERE u.dddi1 = :dddi1"), @NamedQuery(name = "Usuario.findByDdd1", query = "SELECT u FROM Usuario u WHERE u.ddd1 = :ddd1"), @NamedQuery(name = "Usuario.findByNumero1", query = "SELECT u FROM Usuario u WHERE u.numero1 = :numero1"), @NamedQuery(name = "Usuario.findByDdi2", query = "SELECT u FROM Usuario u WHERE u.ddi2 = :ddi2"), @NamedQuery(name = "Usuario.findByDdd2", query = "SELECT u FROM Usuario u WHERE u.ddd2 = :ddd2"), @NamedQuery(name = "Usuario.findByNumero2", query = "SELECT u FROM Usuario u WHERE u.numero2 = :numero2"), @NamedQuery(name = "Usuario.findByDdi3", query = "SELECT u FROM Usuario u WHERE u.ddi3 = :ddi3"), @NamedQuery(name = "Usuario.findByDdd3", query = "SELECT u FROM Usuario u WHERE u.ddd3 = :ddd3"), @NamedQuery(name = "Usuario.findByNumero3", query = "SELECT u FROM Usuario u WHERE u.numero3 = :numero3"), @NamedQuery(name = "Usuario.findByDataUltimaAlteracao", query = "SELECT u FROM Usuario u WHERE u.dataUltimaAlteracao = :dataUltimaAlteracao")})
public class Usuario implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "usuario_id")
    private Integer usuarioId;
    @Basic(optional = false)
    @Column(name = "nome")
    private String nome;
    @Basic(optional = false)
    @Column(name = "email")
    private String email;
    @Basic(optional = false)
    @Column(name = "senha")
    private String senha;
    @Column(name = "data_ultimo_login")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataUltimoLogin;
    @Basic(optional = false)
    @Column(name = "dddi1")
    private String dddi1;
    @Basic(optional = false)
    @Column(name = "ddd1")
    private String ddd1;
    @Basic(optional = false)
    @Column(name = "numero1")
    private int numero1;
    @Column(name = "ddi2")
    private Integer ddi2;
    @Column(name = "ddd2")
    private Integer ddd2;
    @Column(name = "numero2")
    private Integer numero2;
    @Column(name = "ddi3")
    private Integer ddi3;
    @Column(name = "ddd3")
    private Integer ddd3;
    @Column(name = "numero3")
    private Integer numero3;
    @Basic(optional = false)
    @Column(name = "data_ultima_alteracao")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataUltimaAlteracao;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "clienteId", fetch = FetchType.LAZY)
    private List<Manutencao> manutencaoCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "vendedorId", fetch = FetchType.LAZY)
    private List<Compra> compraCollection;
    @JoinColumn(name = "empresa_id", referencedColumnName = "empresa_id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Empresa empresaId;
    @JoinColumn(name = "tipo_usuario_id", referencedColumnName = "tipo_usuario_id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private TipoUsuario tipoUsuarioId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "usuarioId", fetch = FetchType.LAZY)
    private List<Funcionario> funcionarioCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "clienteId", fetch = FetchType.LAZY)
    private List<Venda> vendaCollection;
    @OneToMany(mappedBy = "transportadorId", fetch = FetchType.LAZY)
    private List<Venda> vendaCollection1;

    public Usuario() {
    }

    public Usuario(Integer usuarioId) {
        this.usuarioId = usuarioId;
    }

    public Usuario(Integer usuarioId, String nome, String email, String senha, String dddi1, String ddd1, int numero1, Date dataUltimaAlteracao) {
        this.usuarioId = usuarioId;
        this.nome = nome;
        this.email = email;
        this.senha = senha;
        this.dddi1 = dddi1;
        this.ddd1 = ddd1;
        this.numero1 = numero1;
        this.dataUltimaAlteracao = dataUltimaAlteracao;
    }

    public Integer getUsuarioId() {
        return usuarioId;
    }

    public void setUsuarioId(Integer usuarioId) {
        this.usuarioId = usuarioId;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getSenha() {
        return senha;
    }

    public void setSenha(String senha) {
        this.senha = senha;
    }

    public Date getDataUltimoLogin() {
        return dataUltimoLogin;
    }

    public void setDataUltimoLogin(Date dataUltimoLogin) {
        this.dataUltimoLogin = dataUltimoLogin;
    }

    public String getDddi1() {
        return dddi1;
    }

    public void setDddi1(String dddi1) {
        this.dddi1 = dddi1;
    }

    public String getDdd1() {
        return ddd1;
    }

    public void setDdd1(String ddd1) {
        this.ddd1 = ddd1;
    }

    public int getNumero1() {
        return numero1;
    }

    public void setNumero1(int numero1) {
        this.numero1 = numero1;
    }

    public Integer getDdi2() {
        return ddi2;
    }

    public void setDdi2(Integer ddi2) {
        this.ddi2 = ddi2;
    }

    public Integer getDdd2() {
        return ddd2;
    }

    public void setDdd2(Integer ddd2) {
        this.ddd2 = ddd2;
    }

    public Integer getNumero2() {
        return numero2;
    }

    public void setNumero2(Integer numero2) {
        this.numero2 = numero2;
    }

    public Integer getDdi3() {
        return ddi3;
    }

    public void setDdi3(Integer ddi3) {
        this.ddi3 = ddi3;
    }

    public Integer getDdd3() {
        return ddd3;
    }

    public void setDdd3(Integer ddd3) {
        this.ddd3 = ddd3;
    }

    public Integer getNumero3() {
        return numero3;
    }

    public void setNumero3(Integer numero3) {
        this.numero3 = numero3;
    }

    public Date getDataUltimaAlteracao() {
        return dataUltimaAlteracao;
    }

    public void setDataUltimaAlteracao(Date dataUltimaAlteracao) {
        this.dataUltimaAlteracao = dataUltimaAlteracao;
    }

    public List<Manutencao> getManutencaoCollection() {
        return manutencaoCollection;
    }

    public void setManutencaoCollection(List<Manutencao> manutencaoCollection) {
        this.manutencaoCollection = manutencaoCollection;
    }

    public List<Compra> getCompraCollection() {
        return compraCollection;
    }

    public void setCompraCollection(List<Compra> compraCollection) {
        this.compraCollection = compraCollection;
    }

    public Empresa getEmpresaId() {
        return empresaId;
    }

    public void setEmpresaId(Empresa empresaId) {
        this.empresaId = empresaId;
    }

    public TipoUsuario getTipoUsuarioId() {
        return tipoUsuarioId;
    }

    public void setTipoUsuarioId(TipoUsuario tipoUsuarioId) {
        this.tipoUsuarioId = tipoUsuarioId;
    }

    public List<Funcionario> getFuncionarioCollection() {
        return funcionarioCollection;
    }

    public void setFuncionarioCollection(List<Funcionario> funcionarioCollection) {
        this.funcionarioCollection = funcionarioCollection;
    }

    public List<Venda> getVendaCollection() {
        return vendaCollection;
    }

    public void setVendaCollection(List<Venda> vendaCollection) {
        this.vendaCollection = vendaCollection;
    }

    public List<Venda> getVendaCollection1() {
        return vendaCollection1;
    }

    public void setVendaCollection1(List<Venda> vendaCollection1) {
        this.vendaCollection1 = vendaCollection1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (usuarioId != null ? usuarioId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Usuario)) {
            return false;
        }
        Usuario other = (Usuario) object;
        if ((this.usuarioId == null && other.usuarioId != null) || (this.usuarioId != null && !this.usuarioId.equals(other.usuarioId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return getNome();
    }

}
